package com.das.mechanic_base.adapter.alone;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.das.mechanic_base.R;
import com.das.mechanic_base.bean.alone.AloneImageAndRecordBean;
import com.das.mechanic_base.bean.alone.AloneShareBean;
import com.das.mechanic_base.def.alone.AloneUploadStatus;
import com.das.mechanic_base.utils.X3GlideNewUtils;
import com.das.mechanic_base.utils.X3ScreenUtils;
import com.das.mechanic_base.utils.X3StringUtils;
import com.das.mechanic_base.utils.X3Utils;
import com.das.mechanic_base.widget.X3PointDialog;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class X3ShareAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private List<AloneShareBean> dateList;
    private Context mContext;

    public X3ShareAdapter(Context mContext, List<AloneShareBean> dateList) {
        this.dateList = dateList;
        this.mContext = mContext;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ShareHolder(LayoutInflater.from(mContext).inflate(R.layout.x3_alone_share_item2,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        ShareHolder shareHolder = (ShareHolder) holder;
        AloneShareBean aloneShareBean = dateList.get(position);
        shareHolder.iv_img.setImageResource(aloneShareBean.picId);
        shareHolder.tv_des.setText(aloneShareBean.des);
        shareHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (iOnItemClick != null){
                    iOnItemClick.iOnItemCameraClick(position,aloneShareBean.type);
                }
            }
        });
    }

    IOnItemClick iOnItemClick;

    public void setiOnItemClick(IOnItemClick iOnItemClick) {
        this.iOnItemClick = iOnItemClick;
    }

    public interface IOnItemClick {
        void iOnItemCameraClick(int index,AloneShareBean.ShareType type);
    }

    @Override
    public int getItemCount() {
        return dateList.size();
    }


    class ShareHolder extends RecyclerView.ViewHolder {
        ImageView iv_img;
        TextView tv_des;
        public ShareHolder(@NonNull View itemView) {
            super(itemView);
            iv_img = itemView.findViewById(R.id.iv_img);
            tv_des = itemView.findViewById(R.id.tv_des);
        }
    }
}
